package labuladong.leetcode.editor.cn._02array.ch00;

import java.util.Arrays;

public class _27_RemoveElement {

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int removeElement(int[] nums, int val) {
            int fast = 0, slow = 0;
            while (fast < nums.length) {
                if (nums[fast] != val) {
                    nums[slow] = nums[fast];
                    slow++;
                }
                fast++;
            }
            System.out.println(Arrays.toString(nums));
            return slow;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) {
        Solution solution = new _27_RemoveElement().new Solution();

        int[] nums = {3, 2, 2, 3};
        System.out.println(solution.removeElement(nums, 3));
    }
}
